﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.contracts {
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;

    public class BuyAdoptCommand extends Command {

        public var paymentModel:PaymentModel;
        public var event:InfoEvent;

        override public function execute():void{
            var _local2:Object;
            var _local3:Object;
            var _local4:Object;
            var _local5:InfoEvent;
            var _local1:Array = (this.paymentModel.getData(ProtocolConstants.BUY_ADOPT) as Array);
            for each (_local3 in _local1) {
                if (_local3.name == this.event.id){
                    _local2 = _local3;
                    break;
                };
            };
            if (_local2){
                _local4 = {price:_local2.price, product_id:((_local2.product_id + ":") + this.event.info), product_type:ProtocolConstants.BUY_ADOPT, entity_id:this.event.info};
                _local5 = new InfoEvent(EventConstants.START_PAYMENT, null, _local4);
                dispatch(_local5);
            };
        }

    }
}//package net.wooga.pets.controllers.contracts 
